/******************************
 *
 *
 *****************************/

#ifndef SD_SOCKET_H_20070924
#define SD_SOCKET_H_20070924

#include <stdint.h>
#include <errno.h>

enum SOCK_TYPE {SOCK_CLIENT_TYPE, SOCK_SERVER_TYPE};
enum SNDRCV_TYPE {SOCK_SEND_TYPE=1, SOCK_RECV_TYPE, SOCK_SNDRCV_TYPE};
typedef int sock_t;
#define SOCK_INITIALIZER (-1);

sock_t xopen(const char* ip_address, int port, SOCK_TYPE st);
int xclose(sock_t sd);

sock_t xrecv_client(sock_t sd, uint32_t* client_ip, int* client_port, int timeout_ms);
int xrecv_data(sock_t sd, char* recv_buf, int recv_bytes, int timeout_ms, int timeout_ms2=0);
int xsend_data(sock_t sd, const char* send_buf, int send_bytes, int timeout_ms);

int xset_bufsize(sock_t sd, uint32_t buf_size, SNDRCV_TYPE rwt);

uint32_t get_cur_millseconds();

#endif

